<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="#">首页</a>
            </li>
            <li class="active">
                <a href="#">会员管理</a>
            </li>
        </ul>
    </div>
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12 col-md-12">
                <div class="tab-content tabs-flat no-padding">
                    <div id="visits" class="tab-pane active animated fadeInUp">
                        <div class="row">
                            <div class="col-lg-12 chart-container">
                                <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                                    <div class="widget-body">
                                            <div class="table-toolbar" style="float: left;">
                                                <a href="/luckydog/user/textures" class=" btn btn-default">添加用户</a>
                                            </div>
                                            <div class="table-toolbar" style="float: right;">
                                               <a href="/luckydog/user/import" class=" btn btn-default">批量添加用户</a>
                                            </div>
                                            <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                                <thead>
                                                    <tr>
                                                        <th>USERID</th>
                                                        <th>账号</th>
                                                        <th>姓名</th>
                                                        <th>性别</th>
                                                        <th>部门</th>
                                                        <th>联系方式</th>
                                                        <th>最近使用</th>
                                                        <th>注册时间</th>
                                                       <!--  <th>状态</th>
                                                       <th>操作</th> -->
                                                    </tr>
                                                </thead>
                                                <?php if(!empty($userList)):?>
                                                    <?php foreach($userList as $key=> $row):?>
                                                        <tr class="gradeX ">
                                                            <td class="center" style="text-align:center;width:40px;"><?php echo $row['AccountID']?></td>
                                                            <td class="center"><?=$row['username']?></td>
                                                            <td class="center"><?=$row['truename']?></td>
                                                            <td class="center"><?=$row['sex']==1?"男":"女"?></td>
                                                            <td class="center"><?=$row['department_name']?></td>
                                                            <td class="center"><?=$row['qq']?"QQ:".$row['qq']:''.$row['mobile']?"mobile:".$row['mobile']:''?></td>
                                                            <td class="center"><?= $row['lastlogin']?date("Y-m-d H:i",$row['lastlogin']):"--"?></td>
                                                            <td class="center"><?=$row['addtime']?date("Y-m-d",$row['addtime']):"--"?></td>
                                                            <!-- <td class="center"><?php if($row['Status'] == 1){echo "停用";}else{echo "启用";}?></td>
                                                            <td class="center " data_id = "<?php echo $row['AccountID'];?>">
                                                                <a href="javascript:;" class="edit_account">详情</a>&nbsp;|&nbsp;<a href="javascript:;" class="J_del">删除</a>
                                                                <br/><a href="javascript:;" class="J_Setstatus" status="<?php echo $row['Status']?>"><?php if($row['Status'] != 1){echo "停用";}else{echo "启用";}?></a>
                                                            </td> -->
                                                        </tr>
                                                    <?php endforeach;?>
                                                <?php endif;?>
                                                <tr>
                                                    <td align='center' colspan="21"> <div class="page_links"><?= $page_links?></div></td>
                                                </tr>
                                            </table>
                                        </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?php echo STATICURL; ?>layer/layer.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
    $('.edit_account').on('click', function(){
        //iframe窗
        var id = $(this).parent().attr("data_id");
        layer.open({
            type: 2,
            title: "查看",
            shadeClose: true,
            shade: [0.5, '#000'],
            maxmin: true, //开启最大化最小化按钮
            area: ['750px', '520px'],
            content: '/luckydog/user/touUserInfo?id='+id
        });
    });


    $(document).ready(function() {
        $(".J_search").click(function(){
            var endtime = $("#endtime").val();
            var starttime = $("#starttime").val();
            var name = $("#name").val();
            var contact = $("#contact").val();
            var sign = $("#sign").val();
            var params={
                'starttime':starttime,
                'endtime':endtime,
                'name':name,
                'contact':contact,
                'sign':sign
            };
            location = "/luckydog/user/index?"+$.param(params);
        });

         $(".J_Setstatus").click("click",function(){
            var id = $(this).parent().attr("data_id");
            var status = $(this).attr("status");
            var des = "确定启用吗？";
            if(status == 1){
                status = 0;
                des = "确定要停用吗？";
            }else{
                status = 1;
            }
            if(confirm(des)){
                $.post("/luckydog/user/editStatus",{"id":id,"status":status},function(res){
                    if(res){
                         window.location.reload();
                    }else{
                        alert("添加失败");
                    }
                });
            }
        });
    });

</script>
